﻿using Developer.Core.FrameWork.EventBus.Model;

namespace Developer.Core.FrameWork.EventBus.Service
{
    /// <summary>
    /// 事件总线接口
    /// </summary>
    public interface IEventBus
    {
        /// <summary>
        /// 发布
        /// </summary>
        /// <param name="eventModel">发布模型</param>
        void Publish(EventModel eventModel);

        /// <summary>
        /// 订阅
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TH"></typeparam>
        void Subscribe<T, TH>() where T : EventModel where TH : IEventHandler<T>;


        /// <summary>
        /// 取消订阅
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TH"></typeparam>
        void UnSubscribe<T, TH>() where T : EventModel where TH : IEventHandler<T>;


        /// <summary>
        /// 动态订阅
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="eventName"></param>
        void SubscribeDynamic<T>(string eventName) where T : IDynamicEventHandler;

        /// <summary>
        /// 动态取消订阅
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="eventName"></param>
        void UnSubscribeDynamic<T>(string eventName) where T : IDynamicEventHandler;
    }
}
